/**
 * 
 */
package sismed.gui.comando;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author Berg
 *
 */
public class ComandoLogout extends ComandoGenerico{

	@Override
	public void executar(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try{
			HttpSession session = request.getSession(false);
			session.invalidate();
			response.sendRedirect("login.jsp");
			//request.getRequestDispatcher("/login.html").forward(request, response);
		}catch (Exception e) {
			request.setAttribute("msgErro", e.getMessage());
			String msg ="Erro ao realizar logout.";
			response.sendRedirect("erro.jsp?msgserro="+msg);
			//request.getRequestDispatcher("erro.jsp?msgerro="+msg).forward(request, response);
		}
	}

}
